package main.java.com.lee.syn;

import java.util.stream.IntStream;

/**
 * @Description TODO
 * @Author winston
 * @DateTime 2021/12/21
 */
public class InnerLockTest {

    public static void main(String[] args) throws InterruptedException {

        Object lock = new Object();

        Thread thread = new Thread(()->{
            IntStream.rangeClosed(1, 10).forEach(i->{
                synchronized (lock) {
                    System.out.println(i);
                }
            });
        });
        thread.start();
        thread.join();
    }
}
